package com.kla.power.mapper;

import com.kla.power.entity.MenuEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 菜单权限表 Mapper 接口
 * </p>
 *
 * @author WuZH
 * @since 2024-06-02
 */
@Mapper
public interface MenuMapper extends BaseMapper<MenuEntity> {

    @Select ( value = "<script>SELECT * FROM menu_info mi LEFT JOIN role_menu_info rmi ON mi.id=rmi.menuId " +
            "<trim prefix=\"WHERE\" prefixOverrides=\"and | or\">" +
            "<if test='menuEntity.type!=null'> AND mi.type=#{menuEntity.type} </if>" +
            "<if test='menuEntity.roleId!=null'> AND rmi.roleId=#{menuEntity.roleId} </if>" +
            "<if test='menuEntity.parentId!=null'> AND mi.parentId=#{menuEntity.parentId} </if>" +
            "</trim>ORDER BY mi.sort</script>")
    List<MenuEntity> queryList (@Param ( "menuEntity" ) MenuEntity menuEntity );


}
